package com.xbongbong.saas.toolbox.help;

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.saas.constant.BasicConstant;
import com.xbongbong.saas.constant.StringConstant;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import com.xbongbong.saas.enums.business.QuotationEnum;

import java.util.Objects;

/**
 * @author 吴峰
 * @date 2021/07/15 10:33
 */
public class QuotationUtil {

    /**
     * 设置特殊参数
     *
     * @param businessType
     * @param data
     * @throws
     * @author 吴峰
     * @date 2019-10-19 18:18
     */
    public static Integer setSpecialParam(Integer businessType, JSONObject data) throws XbbException {
        if (Objects.equals(businessType, XbbRefTypeEnum.QUOTATION.getCode())) {
            // 报价单组号不为1.0时，代表创建新版本(目前用于报价单新版本时不用校验同一组号的报价名称)
            String version = FastJsonHelper.getStringOrDefaultFromFormData(data, QuotationEnum.VERSION.getAttr(), StringConstant.DEFAULT_VERSION);
            if (!Objects.equals(version, StringConstant.DEFAULT_VERSION)) {
                return BasicConstant.ONE;
            }
        }
        return null;
    }
}
